package org.tity.support;

import static org.junit.Assert.assertTrue;

import org.junit.jupiter.api.Test;
import org.tity.backends.transfer.Parameter;
import org.tity.commons.collection.MapUtil;
import org.tity.support.pojo.Demo;

import com.alibaba.fastjson.JSON;

public class ParameterTest {

	@Test
	 public void test() {
		 
		 Parameter ps=new Parameter(null);
//		 ps.put("name","leefj");
//		 ps.put("age","24");
//		 ps.put("strArr","['1','3']");
//		 ps.put("familyName","Li");
//		 ps.put("strList","['1','3']");
//		 ps.put("intList","1,2,3,4,5,6");
		 
		 ps.put("id","2020");
		 ps.put("name","leefj");
		 ps.put("age","24");
		 ps.put("strArr","['1','3']");
//		 ps.put("strArr",new String[] {"1","3"});
		 ps.put("familyName","Li");
		 ps.put("strList","['1','3']");
		 ps.put("intList","1,2,3,4,5,6");
		 ps.put("m1","{m:9}");
		 
		 ps.put("parent","{name:'parent',intList:[2,6,7]}");
//		 ps.put("parent",MapUtil.asMap("name","parent"));
		 
		 
 
		Demo demo = ps.extractPOJOEntity(Demo.class);
		 
		 
		 
		 assertTrue(demo!=null);
		 assertTrue(demo.getId().equals("2020"));
		 assertTrue(demo.getAge()==24);
		 assertTrue(demo.getName().equals("leefj"));
		 assertTrue(demo.getFamilyName().equals("Li"));
		 assertTrue(demo.getStrList().size()==2);
		 assertTrue(demo.getIntList().size()==6);
		 assertTrue(demo.getIntList().get(3)==4);
//		 
		 assertTrue(demo.getStrArr().length==2);
		 assertTrue(demo.getStrArr()[1].equals("3"));
		 
		 assertTrue(demo.getM1()!=null);
		 assertTrue(demo.getM1().get("m").equals(9));
 
		 assertTrue(demo.getParent()!=null);
		 
	}
	
	
}
